package com.hk.Mgr.web.controller;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hk.Mgr.web.message.StatusCode;
import com.hk.base.BaseCtrl;
import com.hk.base.ResponseBase;
import com.hk.commons.HqlFilter;
import com.hk.commons.entity.sys.ApiSecret;
import com.hk.service.sys.IApiSecret;

/**
 * @author lemon 用户实现类
 */
@Controller
@RequestMapping(value = BaseCtrl.MgrRootPath + "/apiSecretCtrl")
public class ApiSecretCtrl extends BaseCtrl {

	private Logger logger = LoggerFactory.getLogger(ApiSecretCtrl.class);

	@Autowired
	private IApiSecret apiService;

	/**
	 * @Title: 获取统计结果
	 * @Description:
	 * @param
	 */
	@ResponseBody
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public ResponseBase<List<ApiSecret>> getAllInfo() {
		ResponseBase<List<ApiSecret>> resp = new ResponseBase<List<ApiSecret>>();
		List<ApiSecret> apiList = new ArrayList<ApiSecret>();
		HqlFilter hqlFilter = new HqlFilter();
		apiList = apiService.findByFilter(hqlFilter);
		resp.setResult(apiList);
		resp.setResultCode(StatusCode.SUCCESS.key());
		resp.setSize(apiList.size());
		return resp;
	}

	/**
	 * @Title: 获取统计结果
	 * @Description:
	 * @param
	 */
	@ResponseBody
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public ResponseBase<Boolean> getAllInfoNum(@RequestBody ApiSecret req) {
		ResponseBase<Boolean> resp = new ResponseBase<Boolean>();
		apiService.add(req);
		resp.setResult(true);
		resp.setResultCode(StatusCode.SUCCESS.key());
		return resp;
	}
}
